package com.wilmer.consultants.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.wilmer.common.annotation.Anonymous;
import com.wilmer.consultants.domain.ConsultantsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wilmer.common.annotation.Log;
import com.wilmer.common.core.controller.BaseController;
import com.wilmer.common.core.domain.AjaxResult;
import com.wilmer.common.enums.BusinessType;
import com.wilmer.consultants.domain.BankFinancialConsultants;
import com.wilmer.consultants.service.IBankFinancialConsultantsService;
import com.wilmer.common.utils.poi.ExcelUtil;
import com.wilmer.common.core.page.TableDataInfo;

/**
 * 金融顾问Controller
 * 
 * @author hans
 * @date 2024-04-01
 */
@Api(tags = "金融顾问接口")
@RestController
@RequestMapping("/consultants/consultants")
public class BankFinancialConsultantsController extends BaseController
{
    @Autowired
    private IBankFinancialConsultantsService bankFinancialConsultantsService;

    /**
     * 查询金融顾问列表
     */
    @PreAuthorize("@ss.hasPermi('consultants:consultants:list')")
    @GetMapping("/list")
    public TableDataInfo list(BankFinancialConsultants bankFinancialConsultants)
    {
        startPage();
        List<BankFinancialConsultants> list = bankFinancialConsultantsService.selectBankFinancialConsultantsList(bankFinancialConsultants);
        return getDataTable(list);
    }

    @Anonymous()
    @ApiOperation("小程序前端获取金融顾问列表默认分页10条,可以传入产生根据地区id,获取本地区金融顾问")
    @GetMapping("/getList")
    public TableDataInfo getList(ConsultantsVo consultantsVo)
    {
        startPage();
        List<ConsultantsVo> list = bankFinancialConsultantsService.getList(consultantsVo);
        return getDataTable(list);
    }

    /**
     * 导出金融顾问列表
     */
    @PreAuthorize("@ss.hasPermi('consultants:consultants:export')")
    @Log(title = "金融顾问", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BankFinancialConsultants bankFinancialConsultants)
    {
        List<BankFinancialConsultants> list = bankFinancialConsultantsService.selectBankFinancialConsultantsList(bankFinancialConsultants);
        ExcelUtil<BankFinancialConsultants> util = new ExcelUtil<BankFinancialConsultants>(BankFinancialConsultants.class);
        util.exportExcel(response, list, "金融顾问数据");
    }

    /**
     * 获取金融顾问详细信息
     */
    @ApiOperation("根据金融顾问id获取")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bankFinancialConsultantsService.selectBankFinancialConsultantsById(id));
    }

    /**
     * 新增金融顾问
     */
    @PreAuthorize("@ss.hasPermi('consultants:consultants:add')")
    @Log(title = "金融顾问", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BankFinancialConsultants bankFinancialConsultants)
    {
        return toAjax(bankFinancialConsultantsService.insertBankFinancialConsultants(bankFinancialConsultants));
    }

    /**
     * 修改金融顾问
     */
    @PreAuthorize("@ss.hasPermi('consultants:consultants:edit')")
    @Log(title = "金融顾问", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BankFinancialConsultants bankFinancialConsultants)
    {
        return toAjax(bankFinancialConsultantsService.updateBankFinancialConsultants(bankFinancialConsultants));
    }

    /**
     * 删除金融顾问
     */
    @PreAuthorize("@ss.hasPermi('consultants:consultants:remove')")
    @Log(title = "金融顾问", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bankFinancialConsultantsService.deleteBankFinancialConsultantsByIds(ids));
    }
}
